using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using IGlobalist.Cms.Model;
using IGlobalist.Cms.Bll;
using IGlobalist.Cms.Common;

namespace IGlobalist.Cms.Editors
{
    public partial class GetLinkImageList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                CreateScriptImageList();
            }
        }

        private void CreateScriptImageList()
        {
            IList<IResourceFile> list = ResourceFileController.GetResourceFileList(ResourceType.Image) ;
            string script=@"
                        var tinyMCEImageList = new Array(
	                        {0}
                        );";

            string items = string.Empty;
            foreach (IResourceFile rsFile in list)
            {
                string url=String.Format("../ImageView.aspx?id={0}",rsFile.ID);
                string item=String.Format("['{0}','{1}']", DataUtils.ScriptEscape(rsFile.Name), url);
                items = items+((String.IsNullOrEmpty(items)) ? "" : ",") + item;
            }
            script = String.Format(script, items);

            Response.Clear();
            Response.Write(script);
            Response.Flush();
        }




    }
}
